package com.sikaryofficial.common.core.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * @author : qinjinyuan
 * @desc : 积分业务编码枚举
 * @date : 2023/10/31 17:37
 */
@Getter
@AllArgsConstructor
public enum PointSourceCodeEnum {
    /**
     * 抽奖-大转盘
     */
    LOTTERY_TURNTABLE(PointRuleConstant.LOTTERY_TURNTABLE, "Lottery turntable"),

    /**
     * 抽奖-刮刮乐
     */
    LOTTERY_SCRATCH(PointRuleConstant.LOTTERY_SCRATCH, "Lottery scratch"),

    /**
     * 扫码
     */
    SCAN_CODE(PointRuleConstant.SCAN_CODE, "Scan code"),
    /**
     * 产品评价
     */
    EVALUATE(PointRuleConstant.EVALUATE, "Product evaluate"),
    /**
     * 扫码注册
     */
    SCAN_REGISTER(PointRuleConstant.SCAN_REGISTER, "Scan register"),
    /**
     * 签到
     */
    SIGN_IN(PointRuleConstant.SIGN_IN, "Sign in"),
    /**
     * 门店评价
     */
    STORE_EVALUATE(PointRuleConstant.STORE_EVALUATE, "Store evaluate"),
    /**
     * 预约抢购
     */
    RESERVE_PURCHASE(PointRuleConstant.RESERVE_PURCHASE, "Reserve purchase"),
    /**
     * 礼品兑换
     */
    GIFT_REDEEM(PointRuleConstant.GIFT_REDEEM, "Gift redeem"),
    /**
     * 预约抽奖
     */
    RESERVE_LOTTERY(PointRuleConstant.RESERVE_LOTTERY, "Reserve lottery"),
    /**
     * 首页发帖
     */
    ARTICLE_PUBLISH_HOME(PointRuleConstant.ARTICLE_PUBLISH_HOME, "First article publish"),
    /**
     * 完善个人信息
     */
    OWNER_INFO_MODIFY(PointRuleConstant.OWNER_INFO_MODIFY, "Owner info modify"),
    /**
     * 收到的文章点赞
     */
    ARTICLE_RECEIVED_LIKE(PointRuleConstant.ARTICLE_RECEIVED_LIKE, "Article received like"),
    /**
     * 浏览时长
     */
    BROWSE_DURATION_HOME(PointRuleConstant.BROWSE_DURATION_HOME, "Browse duration home"),
    /**
     * 文章评价
     */
    ARTICLE_EVALUATE(PointRuleConstant.ARTICLE_EVALUATE, "Article evaluate"),
    /**
     * 文章评价回复
     */
    ARTICLE_EVALUATE_REPLY(PointRuleConstant.ARTICLE_EVALUATE_REPLY, "Article evaluate reply"),
    /**
     * 文章点赞
     */
    ARTICLE_LIKE(PointRuleConstant.ARTICLE_LIKE, "Article like");

    /**
     * 编码
     */
    private final String code;

    /**
     * 描述
     */
    private final String desc;

    public static PointSourceCodeEnum getByCode(String code) {
        return Arrays.stream(PointSourceCodeEnum.values())
                .filter(channelEnum -> channelEnum.getCode().equals(code))
                .findFirst().orElse(null);
    }

    public static String getDescByCode(String code) {
         PointSourceCodeEnum codeObject = getByCode(code);
          if (codeObject == null) {
              return "-";
          }
          return Optional.ofNullable(codeObject.getDesc()).orElse("-");
    }

}
